<!DOCTYPE html>
<html lang="zh-CN" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head th:include="/common/inc::header"/>
<body>
<form class="layui-form" style="margin-top: 15px">
    <button class="layui-btn" id="searchBtn" lay-submit lay-filter="searchBtn" style="margin-left: 30px">查询</button>
</form>
<table class="layui-table" id="grid" lay-filter="grid">
</table>
<script th:replace="/common/inc::incJs"></script>
<script>
    var tableIns;

    $(function () {
        tableIns = createTable({
            url: 'list',
            cols: [[{field: 'id', title: '编号', width: 60},
                {field: 'beforeLog', title: '修改前数据', width: 500}
                , {field: 'afterLog', title: '修改后数据', width: 500},{field: 'remark', title: '备注', width: 100},  {
                    field: 'operatingId',
                    title: '修改人ID',
                    width: 120
                }, {
                    field: 'operatingName',
                    title: '修改人姓名',
                    width: 180
                }, {
                    field: 'createTime',
                    title: '操作时间',
                    width: 180
                }
            ]]
        });
    });

    layui.table.on('tool(grid)', function (obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
        var data = obj.data; //获得当前行数据
        var layEvent = obj.event; //获得 lay-event 对应的值
        var tr = obj.tr; //获得当前行 tr 的DOM对象02\
        if (layEvent === 'change') { //删除
            changeStatus(data.id, data.delBoolean);
        } else if (layEvent === 'edit') { //编辑
            openDialog({
                url: "/backend/security/news/detail?id=" + data.id,
                area: ["70%", "80%"]
            });
        } else if (layEvent === 'del') { //删除
            delRecord("/backend/security/news/del", obj)
        }
    });


    layui.form.on('submit(addBtn)', function () {
        openDialog({
            url: "/backend/security/news/detail",
            area: ["70%", "80%"]
        });
        return false;
    });

    layui.form.on('submit(searchBtn)', function (data) {
        tableIns.reload({
            where: data.field
        });
        return false;
    });

</script>
</body>
</html>
